package com.lbs.jiepiaisi.style.citylist.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.lbs.jiepiaisi.bean.CityEntity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 作者：liji on 2017/5/19 17:07
 * 邮箱：lijiwork@sina.com
 * QQ ：275137657
 */

public class CityInfoBean implements Parcelable,Serializable {

    
    private String id; /*110101*/
    
    private String name; /*东城区*/

    private String abbr;

    private String cityCode;

    private String cityName;

    private String province;

    private String provinceCode;

    private String engine;

    private String engineno;

    private String classa;

    private String classno;

    public String getEngine() {
        return engine;
    }

    public void setEngine(String engine) {
        this.engine = engine;
    }

    public String getEngineno() {
        return engineno;
    }

    public void setEngineno(String engineno) {
        this.engineno = engineno;
    }

    public String getClassa() {
        return classa;
    }

    public void setClassa(String classa) {
        this.classa = classa;
    }

    public String getClassno() {
        return classno;
    }

    public void setClassno(String classno) {
        this.classno = classno;
    }

    public String getAbbr() {
        return abbr;
    }

    public void setAbbr(String abbr) {
        this.abbr = abbr;
    }

    public String getCityCode() {
        return cityCode;
    }

    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getProvinceCode() {
        return provinceCode;
    }

    public void setProvinceCode(String provinceCode) {
        this.provinceCode = provinceCode;
    }
    
    private ArrayList<CityInfoBean> cityList;



    public ArrayList<CityInfoBean> getCityList() {
        return cityList;
    }
    
    public void setCityList(ArrayList<CityInfoBean> cityList) {
        this.cityList = cityList;
    }
    
    public CityInfoBean() {
    }
    
    public static CityInfoBean findCity(List<CityInfoBean> list, String cityName) {
        try {
            for (int i = 0; i < list.size(); i++) {
                CityInfoBean city = list.get(i);
                if (cityName.equals(city.getName()) || cityName.contains(city.getName())
                        || city.getName().contains(cityName)) {
                    return city;
                }
            }
        }
        catch (Exception e) {
            return null;
        }
        return null;
    }


    public String getId() {
        return id == null ? "" : id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name == null ? "" : name;
    }

    public void setName(String name) {
        this.name = name;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeString(this.name);
        dest.writeTypedList(this.cityList);
        dest.writeString(this.abbr);
        dest.writeString(this.cityCode);
        dest.writeString(this.province);
        dest.writeString(this.cityName);
        dest.writeString(this.provinceCode);
        dest.writeString(this.engine);
        dest.writeString(this.engineno);
        dest.writeString(this.classa);
        dest.writeString(this.classno);
    }

    protected CityInfoBean(Parcel in) {
        this.id = in.readString();
        this.name = in.readString();
        this.cityList = in.createTypedArrayList(CityInfoBean.CREATOR);
        this.abbr = in.readString();
        this.cityCode = in.readString();
        this.province = in.readString();
        this.cityName = in.readString();
        this.provinceCode = in.readString();
        this.engine = in.readString();
        this.engineno = in.readString();
        this.classa = in.readString();
        this.classno = in.readString();

    }

    public static final Creator<CityInfoBean> CREATOR = new Creator<CityInfoBean>() {
        @Override
        public CityInfoBean createFromParcel(Parcel source) {
            return new CityInfoBean(source);
        }

        @Override
        public CityInfoBean[] newArray(int size) {
            return new CityInfoBean[size];
        }
    };
}
